package com.albaba.designpattern.mediator.text_002;

/**
 * @Description: 具体的中介者-中介机构
 * @Author zx
 * @Date 2025/3/3 16:52
 * @Version 1.0
 */
public class MediatorStructure extends Mediator{

    // 中介知晓 房屋出租人和承租人的信息
    private HouseOwner houseOwner; // 房屋出租人

    private Tenant tenant; // 承租人


    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void contact(String msg, Person person) {

        if (person == houseOwner){
            // 如果是房主，则通知承租人
            tenant.getMessage(msg);
        }
        if (person == tenant){
            // 如果是承租人，则通知房主
            houseOwner.getMessage(msg);
        }

    }
}
